
#ifndef INCLUDED_XMPPLOGINTASK_H
#define INCLUDED_XMPPLOGINTASK_H

#include "xmpptask.h"
#include "jid.h"
#include <string>

namespace tinkle {

class XmppLoginTask : public XmppTask{
public:
    enum State {
        LS_INIT,
        LS_STREAMINIT_SENT,
        LS_STREAMINIT_RECVED,
        LS_FEATURES_NOTIFY,
        LS_TLS_REQUESTED,
        LS_TLSINIT_SENT,
        LS_TLSINIT_RECVED,
        LS_TLSSTREAMINIT_SENT,
        LS_TLSSTREAMINIT_RECVED,
        LS_TLSFEATURES_NOTIFY,
        LS_SASL_SENT,
        LS_SASL_SUCCESS,
        LS_SASLSTREAMINIT_SENT,
        LS_SASLSTREAMINIT_RECVED,
        LS_REQUEST_SENT,
        LS_BINDED,
        LS_DONE
    };
    XmppLoginTask(const std::string &user, const std::string &pwd,
        BaseTask *parent);
    ~XmppLoginTask();
    bool Abort();
    // get the jid
    const Jid & GetJid() const;

    bool NextStanza(XmlNode *stanza);

private:
    void ProcessReady();
    XmlNode _stanza;
    std::string _user;
    std::string _pwd;
    State _state;
    Jid _jid;
};

}

#endif